<!DOCTYPE html>
<html lang="zh-CN">
  <head>
    <meta charset="utf-8" />
    <meta
      name="viewport"
      content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no, minimal-ui"
    />
    <title>Android使用maven镜像应对国内被墙不能下载依赖包的问题 | zzqhost</title>
    <meta name="description" content="天行健，君子以自强不息；地势坤，君子以厚德载物" />
    <meta property="og:type" content="website" />
    <meta property="og:title" content="Android使用maven镜像应对国内被墙不能下载依赖包的问题 | zzqhost" />
    <meta property="og:site_name" content="Android使用maven镜像应对国内被墙不能下载依赖包的问题 | zzqhost" />
    <meta property="og:locale" content="zh-CN" />
    <meta name="twitter:card" content="summary" />
    <meta name="twitter:title" content="Android使用maven镜像应对国内被墙不能下载依赖包的问题 | zzqhost" />
    <link rel="shortcut icon" href="/favicon.ico">
    
    <link rel="preload" href="/assets/css/0.styles.948dbb0a.css" as="style"><link rel="preload" href="/assets/js/app.3e01f5cb.js" as="script"><link rel="preload" href="/assets/js/1.21aaee9f.js" as="script"><link rel="preload" href="/assets/js/14.98a4de9c.js" as="script"><link rel="preload" href="/assets/js/5.352c1a43.js" as="script"><link rel="preload" href="/assets/js/7.4a8a313c.js" as="script"><link rel="preload" href="/assets/js/9.5ce2172b.js" as="script"><link rel="preload" href="/assets/js/6.8b8fad13.js" as="script"><link rel="preload" href="/assets/js/21.cdbb212e.js" as="script"><link rel="preload" href="/assets/js/13.186562af.js" as="script"><link rel="preload" href="/assets/js/15.740f4afc.js" as="script"><link rel="prefetch" href="/assets/js/10.e3f309c4.js"><link rel="prefetch" href="/assets/js/11.7bef5ef0.js"><link rel="prefetch" href="/assets/js/12.cf546b2f.js"><link rel="prefetch" href="/assets/js/16.c0f3e779.js"><link rel="prefetch" href="/assets/js/17.ee3f21b3.js"><link rel="prefetch" href="/assets/js/18.2c35035c.js"><link rel="prefetch" href="/assets/js/19.e4881cfc.js"><link rel="prefetch" href="/assets/js/20.95040517.js"><link rel="prefetch" href="/assets/js/22.7d278bc3.js"><link rel="prefetch" href="/assets/js/23.1e2b813e.js"><link rel="prefetch" href="/assets/js/24.6cc55189.js"><link rel="prefetch" href="/assets/js/25.ea35ed40.js"><link rel="prefetch" href="/assets/js/26.2b97bfde.js"><link rel="prefetch" href="/assets/js/27.d323aa74.js"><link rel="prefetch" href="/assets/js/28.30416d07.js"><link rel="prefetch" href="/assets/js/29.02b97357.js"><link rel="prefetch" href="/assets/js/30.95aedede.js"><link rel="prefetch" href="/assets/js/31.79b824fd.js"><link rel="prefetch" href="/assets/js/32.d0cd6341.js"><link rel="prefetch" href="/assets/js/33.14c3c5b9.js"><link rel="prefetch" href="/assets/js/34.ac56f38e.js"><link rel="prefetch" href="/assets/js/35.54820345.js"><link rel="prefetch" href="/assets/js/36.37013d97.js"><link rel="prefetch" href="/assets/js/37.38353206.js"><link rel="prefetch" href="/assets/js/38.36296a20.js"><link rel="prefetch" href="/assets/js/39.37df68d6.js"><link rel="prefetch" href="/assets/js/4.54d65165.js"><link rel="prefetch" href="/assets/js/40.ffbd7a88.js"><link rel="prefetch" href="/assets/js/41.5db561d2.js"><link rel="prefetch" href="/assets/js/42.d876627b.js"><link rel="prefetch" href="/assets/js/43.e5008459.js"><link rel="prefetch" href="/assets/js/44.a24dc4a2.js"><link rel="prefetch" href="/assets/js/45.f696c4e1.js"><link rel="prefetch" href="/assets/js/8.8c0e5954.js"><link rel="prefetch" href="/assets/js/vendors~search.c4563fd1.js">
    <link rel="stylesheet" href="/assets/css/0.styles.948dbb0a.css">
  </head>
  <body>
    <div id="loader-wrapper" style="display: none;opacity:0">
      <div id="loader"></div>
      <div class="loader-section section-left"></div>
      <div class="loader-section section-right"></div>
    </div>
    <div id="app" data-server-rendered="true"><div style="height:100%;" data-v-80d5f2bc><section class="el-container main-container" data-v-80d5f2bc><aside class="el-aside menu" style="width:auto;" data-v-67e96130 data-v-80d5f2bc><ul role="menubar" class="menu-wrap el-menu" style="background-color:;" data-v-67e96130><li data-v-67e96130><div class="brand-wrap" style="background-image:url(/brand.jpg);" data-v-67e96130><div class="brand" data-v-67e96130><a href="/" class="avatar waves-effect waves-circle waves-light router-link-active" data-v-67e96130><img src="/avatar.jpg" data-v-67e96130></a> <hgroup class="introduce" data-v-67e96130><div class="nickname" data-v-67e96130>zzqhost</div> <a title="zzqhost@163.com" class="mail" data-v-67e96130>zzqhost@163.com</a></hgroup></div></div></li> <li role="menuitem" tabindex="-1" class="el-menu-item" style="padding-left:20px;color:;background-color:;" data-v-67e96130><i class="iconfont icon-home" data-v-67e96130></i> <span class="item-title" data-v-67e96130>主页</span></li> <li role="menuitem" tabindex="-1" class="el-menu-item" style="padding-left:20px;color:;background-color:;" data-v-67e96130><i class="iconfont icon-biaoqian" data-v-67e96130></i> <span class="item-title" data-v-67e96130>标签分类</span></li> <li role="menuitem" tabindex="-1" class="el-menu-item" style="padding-left:20px;color:;background-color:;" data-v-67e96130><i class="iconfont icon-wenzhang" data-v-67e96130></i> <span class="item-title" data-v-67e96130>时间归档</span></li> <!----> <li role="menuitem" tabindex="-1" class="el-menu-item" style="padding-left:20px;color:;background-color:;" data-v-67e96130><i class="iconfont icon-aboutme" data-v-67e96130></i> <span class="item-title" data-v-67e96130>自我介绍</span></li></ul></aside> <section class="el-container container-warp" data-v-80d5f2bc><header id="topHeader" class="el-header top-header" style="height:60px;padding-left:260px;" data-v-1a942948 data-v-80d5f2bc><div class="header-warp el-row is-align-middle el-row--flex" data-v-1a942948><div class="el-col el-col-12 el-col-xs-7" data-v-1a942948><div class="el-row is-align-middle el-row--flex" data-v-1a942948><div class="el-col el-col-2" data-v-1a942948><button type="button" class="el-button el-button--primary is-circle" data-v-1a942948><!----><!----><span><i class="iconfont icon-caidan" data-v-1a942948></i></span></button></div></div></div> <div class="el-col el-col-20 el-col-xs-24" data-v-1a942948><div class="grid-content bg-purple-light" data-v-1a942948><div class="el-row is-justify-end is-align-middle el-row--flex" data-v-1a942948><div class="el-col el-col-13 el-col-xs-24 el-col-sm-21 el-col-md-17 el-col-lg-13" data-v-1a942948><div aria-haspopup="listbox" role="combobox" aria-owns="el-autocomplete-136" class="el-autocomplete search-input" data-v-1a942948><div class="el-input el-input--small el-input--suffix"><!----><input type="text" autocomplete="off" valueKey="value" popperClass="search-popper" placeholder="搜搜看" fetchSuggestions="function () { [native code] }" debounce="300" placement="bottom-start" popperAppendToBody="true" value="" class="el-input__inner"><!----><span class="el-input__suffix"><span class="el-input__suffix-inner"><i class="el-input__icon el-icon-search search-ico" data-v-1a942948></i><!----></span><!----></span><!----></div><div role="region" class="el-autocomplete-suggestion el-popper search-popper" style="width:;display:none;"><div class="el-scrollbar"><div class="el-autocomplete-suggestion__wrap el-scrollbar__wrap el-scrollbar__wrap--hidden-default"><ul class="el-scrollbar__view el-autocomplete-suggestion__list"></ul></div><div class="el-scrollbar__bar is-horizontal"><div class="el-scrollbar__thumb" style="width:0;transform:translateX(0%);ms-transform:translateX(0%);webkit-transform:translateX(0%);"></div></div><div class="el-scrollbar__bar is-vertical"><div class="el-scrollbar__thumb" style="height:0;transform:translateY(0%);ms-transform:translateY(0%);webkit-transform:translateY(0%);"></div></div></div></div></div></div></div></div></div></div></header> <main class="el-main my-main" style="margin-left:240px;" data-v-105de776 data-v-80d5f2bc><div class="content-header index-header" data-v-60d87e45 data-v-105de776><div class="container fade-scale in" data-v-60d87e45><h1 id="conentHeader" class="title" data-v-60d87e45>Android使用maven镜像应对国内被墙不能下载依赖包的问题</h1> <h5 class="subtitle" data-v-60d87e45>最后更新时间：2019-09-17 11:56:05</h5></div></div> <div data-v-95d4b5b2 data-v-105de776 data-v-105de776><div class="post-content el-row is-justify-center el-row--flex" data-v-95d4b5b2><div id="post-card" class="post-card post-sign el-col el-col-16 el-col-xs-24 el-col-sm-23 el-col-md-23 el-col-lg-16" data-v-95d4b5b2><div class="content__default" data-v-95d4b5b2><p>在国内做个开发不容易啊，要精通各种技能，比如说英文，数学，算法，概率，其中还有一项必备技能就是翻墙，但是作为一个吊丝程序员就比较麻烦了，免费的不好用，慢，还经常不能使用，得经常换。 本文介绍了一种不用翻墙就能轻松应对Android使用mavenCentral，jCenter，google maven仓库的问题。
</p> <h2 id="原理"><a href="#原理" aria-hidden="true" class="header-anchor">#</a> 原理</h2> <ol><li>将项目中的mavenCentral、jCenter、google maven仓库替换为aliyun镜像，阿里云镜像访问还是蛮快的</li> <li>替换方法是使用本地脚本，在sync项目时自动进行替换，这样对多个项目都起作用，而且将来还能轻松换回来</li></ol> <h2 id="步骤"><a href="#步骤" aria-hidden="true" class="header-anchor">#</a> 步骤</h2> <ol><li>下载<a href="../files/init.gradle">脚本</a></li> <li>将init.gradle脚本放到家路径的 .gradle 目录下
<ol><li>比如 linux 是 ~/.gradle/ 下</li> <li>windows 是 c:\users\Administrator(或你的用户名)\.gradle</li></ol></li> <li>重新启动android studio，点一下sync试试吧</li></ol></div> <span id="footerPost" data-v-95d4b5b2></span></div> <div id="post-toc" class="post-toc el-col el-col-6" data-v-95d4b5b2><h4 class="catalog-title" data-v-95d4b5b2>TOC</h4> <div class="catalog-body" data-v-95d4b5b2><ul id="catalog-list" class="catalog-list" data-v-95d4b5b2></ul></div></div></div> <div class="post-nav el-row is-justify-space-around el-row--flex" data-v-95d4b5b2><div class="post-prev el-col el-col-7" data-v-95d4b5b2><div data-v-95d4b5b2><a href="/posts/%E4%BD%BF%E7%94%A8.netrc%E5%AE%9E%E7%8E%B0git%E5%85%8D%E5%AF%86%E4%B8%8A%E4%BC%A0%E4%B8%8B%E8%BD%BD%EF%BC%88http%E5%8D%8F%E8%AE%AE%EF%BC%89.html" data-v-95d4b5b2><i class="el-icon-arrow-left" data-v-95d4b5b2></i> Prev
        </a> <p class="nav-title" data-v-95d4b5b2>使用.netrc实现git免密上传下载（http协议）</p></div></div> <div class="post-next el-col el-col-7 el-col-lg-pull-5" data-v-95d4b5b2><div data-v-95d4b5b2><a href="/posts/%E7%BB%99git-pull%E5%8A%A0%E4%B8%8A%E9%BB%98%E8%AE%A4rebase%E5%8A%9F%E8%83%BD.html" data-v-95d4b5b2>
          Next
          <i class="el-icon-arrow-right" data-v-95d4b5b2></i></a> <p class="nav-title" data-v-95d4b5b2>给git pull加上默认rebase功能</p></div></div></div> <div class="el-row is-justify-center el-row--flex" data-v-95d4b5b2></div> <span data-v-d999c3f2 data-v-95d4b5b2><button type="button" class="el-button toc-btn el-button--primary is-circle" data-v-d999c3f2><!----><!----><span><i class="iconfont icon-service-directory" data-v-d999c3f2></i></span></button> <button type="button" class="el-button gotop-btn el-button--primary is-circle" data-v-d999c3f2><!----><!----><span><i class="el-icon-arrow-up" data-v-d999c3f2></i></span></button></span></div></main></section> <button type="button" class="el-button gotop-btn el-button--primary is-circle" style="display:none;" data-v-78a2dcfa data-v-80d5f2bc><!----><!----><span><i class="el-icon-arrow-up" data-v-78a2dcfa></i></span></button></section> <footer class="el-footer container-footer" style="height:60px;" data-v-76c50ee3 data-v-80d5f2bc><div class="footer-warp el-row is-justify-center is-align-center el-row--flex footerMargin" data-v-76c50ee3><div class="footer-top el-col el-col-24" data-v-76c50ee3><p class="ellipsis" data-v-76c50ee3><span data-v-76c50ee3>
          博客内容遵循
          <a rel="license" href="https://creativecommons.org/licenses/by-nc-sa/4.0/deed.zh" data-v-76c50ee3>知识共享 署名 - 非商业性 - 相同方式共享 4.0 国际协议</a></span></p></div> <div class="footer-bottom el-col el-col-24" data-v-76c50ee3><p class="ellipsis" data-v-76c50ee3><span data-v-76c50ee3><span data-v-76c50ee3>
            张志强的博客 © 2017-01 ~ 2021-03
          </span></span> <span data-v-76c50ee3>
          Power by
          <a href="https://vuepress.vuejs.org/zh/" target="_blank" data-v-76c50ee3>VuePress</a> Theme
          <a href="https://github.com/zhhlwd/vuepress-theme-indigo-material" target="_blank" data-v-76c50ee3>indigo material</a></span></p></div></div></footer> <div class="overlay" data-v-80d5f2bc></div></div><div class="global-ui"></div></div>
    <script src="/assets/js/app.3e01f5cb.js" defer></script><script src="/assets/js/1.21aaee9f.js" defer></script><script src="/assets/js/14.98a4de9c.js" defer></script><script src="/assets/js/5.352c1a43.js" defer></script><script src="/assets/js/7.4a8a313c.js" defer></script><script src="/assets/js/9.5ce2172b.js" defer></script><script src="/assets/js/6.8b8fad13.js" defer></script><script src="/assets/js/21.cdbb212e.js" defer></script><script src="/assets/js/13.186562af.js" defer></script><script src="/assets/js/15.740f4afc.js" defer></script>
  </body>
</html>
